package com.mytest;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo04 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<String> stringFutureTask = new FutureTask<>(new MyCallable());
        new Thread(stringFutureTask).start();
        System.out.println(stringFutureTask.get());
        System.out.println(Runtime.getRuntime().availableProcessors());
    }
}

class MyCallable implements Callable<String> {

    @Override
    public String call() throws Exception {

        return "hello";
    }
}
